package com.dao;

import com.domain.Resources;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository("resourceDao")
public interface ResourceDao {

    //根据创建时间查询
    List<Resources> descCreateDate(@Param("space_id")Integer space_id);

    List<Resources> selectResourceByMemberId( @Param("member_id")Integer member_id);

    //根据标题名模糊查询资源
    List<Resources> selectResourceByTitle(@Param("title")String title);

    Resources selectResourceByTitleAndMemberId(@Param("title") String title, @Param("member_id") Integer member_id);

    //查询资源总数：
    int findResourceTotal(@Param("space_id")Integer space_id);

    //显示所有资源信息
     List<Resources> showResource(@Param("space_id")Integer space_id);

    //分页查询
     List<Resources> findAllByPage(@Param("space_id")int space_id,@Param("from")int from,@Param("pageSize")int pageSize);

    //根据资源id显示资源信息
     Resources showResourceById(@Param("id")Integer id);

    //根据资源id和空间id显示资源信息
    Resources showResourceByIdAndSpaceId(@Param("id")Integer id,@Param("space_id")Integer space_id);

    //根据id删除资源
     Integer deleteByResourceId(@Param("id")Integer id);

    //根据资源名，作者，标签进行模糊查询
     List BlurredSelect(@Param("space_id")Integer space_id,@Param("title")String title,@Param("author")String author,@Param("label")String label);

    //根据资源id进行修改
     Integer updateResource(@Param("id")Integer id,@Param("title")String title,@Param("content")String content,
                                  @Param("detail")String detail,@Param("label")String label,@Param("updatetime")Date updatetime);

    //添加资源
     Integer insertResource(@Param("title")String title,@Param("content")String content,@Param("author")String author,
                            @Param("detail")String detail,@Param("label")String label, @Param("createdate")Date createdate,
                            @Param("updatetime")Date updatetime,@Param("member_id")Integer member_id, @Param("space_id")Integer space_id);

    //查询最后一条语句
     Resources findLastId();

     int deleteResourceBySpaceId(int space_id);

}
